{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "1f94d7de",
   "metadata": {},
   "source": [
    "## 1.np.linspace()-生成线性间隔的数组"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "49ec5759",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[ 0.          1.11111111  2.22222222  3.33333333  4.44444444  5.55555556\n",
      "  6.66666667  7.77777778  8.88888889 10.        ]\n",
      "[0. 1. 2. 3. 4. 5. 6. 7. 8. 9.]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "# 生成从0到10的10个均匀间隔的数\n",
    "arr = np.linspace(0,10,10)\n",
    "print(arr)\n",
    "\n",
    "# 如果不包括终点\n",
    "arr_no_endpoint = np.linspace(0,10,10,endpoint=False)\n",
    "print(arr_no_endpoint)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d757e5df",
   "metadata": {},
   "source": [
    "## 2.`np.arange()` —— 生成固定步长的数组    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e3a1a30b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0 2 4 6 8]\n",
      "[0 1 2 3 4 5 6 7 8 9]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "# np.arange([start, ]stop, [step, ], dtype=None)\n",
    "# np.arange默认不包含stop\n",
    "# 生成从0到10（不包括10），步长为2的数组\n",
    "arr = np.arange(0,10,2)\n",
    "print(arr)\n",
    "\n",
    "# 默认步长为1\n",
    "arr_default_step = np.arange(0,10)\n",
    "print(arr_default_step)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cb4c6e95",
   "metadata": {},
   "source": [
    "## 3.`np.logspace()` —— 生成对数间隔的数组"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "79012860",
   "metadata": {},
   "outputs": [],
   "source": [
    "# np.logspace(start, stop, num=50, endpoint=True, base=10.0, dtype=None, axis=0)\n",
    "\n",
    "import numpy as np\n",
    "# 生成10的对数尺度上从10^0到10^3的10个数\n",
    "arr_logspace = np.logspace(0,3,10)\n",
    "print(arr_logspace)\n",
    "\n",
    "# 生成自然对数（以e为底）的对数间隔数组\n",
    "arr_e = np.logspace(0, 3, 10, base=np.e)\n",
    "print(arr_e)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
